/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.awt.Toolkit;
import java.awt.datatransfer.Transferable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javafx.scene.image.Image;

/**
 *
 * @author Johnthan
 */
public class Album {
    private ArrayList<Photo> innerPhoto;
    private Image cover;
    private boolean isCommonAlbum ;
    private boolean isAlwaysShow ;
    private double size;
    private int sumOfPhoto ;
    private double previewLevel;

    public Album() {
    }
    
    /**
     * @return the innerPhoto
     */
    public ArrayList getInnerPhoto() {
        return innerPhoto;
    }

    /**
     * @param innerPhoto the innerPhoto to set
     */
    public void setInnerPhoto(ArrayList<Photo> innerPhoto) {
        this.innerPhoto = innerPhoto;
    }

    /**
     * @return the isCommonAlbum
     */
    public boolean isIsCommonAlbum() {
        return isCommonAlbum;
    }

    /**
     * @param isCommonAlbum the isCommonAlbum to set
     */
    public void setIsCommonAlbum(boolean isCommonAlbum) {
        this.isCommonAlbum = isCommonAlbum;
    }

    /**
     * @return the size
     */
    public double getSize() {
        int i,k = innerPhoto.size();
        double size = 0;
        for(i=0;i<k;i++)
        {
            size = innerPhoto.get(i).getSize() + size;
        }
        return size;
    }

    /**
     * @return the sumOfPhoto
     */
    public int getSumOfPhoto() {
        return innerPhoto.size();
    }

    /**
     * @return the previewLevel
     */
    public double getPreviewLevel() {
        return previewLevel;
    }

    /**
     * @param previewLevel the previewLevel to set
     */
    public void setPreviewLevel(double previewLevel) {
        this.previewLevel = previewLevel;
    }
    
     /**
     * @return the isAlwaysShow
     */
    public boolean isIsAlwaysShow() {
        return isAlwaysShow;
    }

    /**
     * @param isAlwaysShow the isAlwaysShow to set
     */
    public void setIsAlwaysShow(boolean isAlwaysShow) {
        this.isAlwaysShow = isAlwaysShow;
    }
    
    public void copy(Photo photo){
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents((Transferable) photo,null);
    }
    
    public void cut(Photo photo){
        this.copy(photo);
        this.delete(photo);
    }
    
    public void delete(Photo photo){
        innerPhoto.remove(photo);
    }
    
    public void paste(){
        Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
        innerPhoto.add((Photo)t);
    }
    
    public void reName(Photo photo,String name){
        photo.setName(name);
    }
    
    public Image getCover(){
        return this.cover;
    }
    
    public void setCover(Image image){
        this.cover = image;
    }
    
    public void reNameALLPhoto(String name){
        int i,k = innerPhoto.size();
        DecimalFormat tool = new DecimalFormat("0000");
        for(i=0;i<k;i++)
        {
            innerPhoto.get(0).setName(name + tool.format(i));
        }
    }
    
    public void add(Photo photo){
        innerPhoto.add(photo);
    }

   
    
    
}
